package cn.honqun.tinycms.service;

import cn.hutool.core.lang.generator.SnowflakeGenerator;

public final class IdGenerator {
    private static volatile SnowflakeGenerator snowflakeGenerator = null;

    public static long nextId() {
        if (snowflakeGenerator == null) {
            synchronized (IdGenerator.class) {
                if (snowflakeGenerator == null) {
                    snowflakeGenerator = new SnowflakeGenerator(1, 1);
                }
            }
        }
        return snowflakeGenerator.next();
    }
}
